# 登录验证
def acc_login(user_data):
    retry_count = 0  # 重试次数
    while user_data['is_authenticated'] is not True and retry_count < 3:
        # 输入用户名与密码
        account = input("\033[32;1maccount:\033[0m").strip()
        password = input("\033[32;1mpassword:\033[0m").strip()
        auth = acc_auth(account, password)
        if auth:  # not None means passed the authentication
            user_data['is_authenticated'] = True
            user_data['account_id'] = account
            # print("welcome")
            return auth
        retry_count += 1
        print("还可以输入{TIME}次".format(TIME=3-retry_count))
    else:
        print("您已经试过多次了,请稍后再试!")
        exit()

# 验证用户名,密码
def acc_auth(account,password):
    # 从数据可中读取用户名与密码进行验证
    user_data={
        "username": 'houzheng',
        "password": "799827577"
    }
    return user_data